package adc.app.ui.wicket.session;

import java.io.Serializable;

/**
 * Session scoped Spring bean storing the id of the current user.
 * 
 * Together {@link RequestUserContext} makes posible the injection of the
 * current user context in the business.
 * 
 * @author Alex
 *
 */
public class SessionUserContext implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private Long userId;

	/**
	 * Getter for the user id.
	 */
	public Long getUserId() {
		return userId;
	}

	/**
	 * Setter for the user id.
	 */
	public void setUserId(Long userId) {
		this.userId = userId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((userId == null) ? 0 : userId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SessionUserContext other = (SessionUserContext) obj;
		if (userId == null) {
			if (other.userId != null)
				return false;
		} else if (!userId.equals(other.userId))
			return false;
		return true;
	}
	
	
}
